#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;
const int N = 4e5 + 10;
int n, root;
vector<int> e[N];
int cnt[N],  // cnt[u]表示除了子树 u 以外,大小最大但是不超出
    sz[N];   // n/2的子树大小 sz[u]表示子树 u 的子树大小

// f[u][0/1] 表示子树 u 中大小最大但是不超出 n/2 的子树最大值/次大值
int f[N][2];
int res[N];                // 记录答案
void dfs(int u, int fa) {  // 找重心
  sz[u] = 1;
  int flag = 1;
  for (auto v : e[u]) {
    if (v == fa) continue;
    dfs(v, u);
    sz[u] += sz[v];
    if (sz[v] > n / 2) flag = 0;
  }
  if (n - sz[u] > n / 2) flag = 0;
  if (flag) root = u;
}
void dfs1(int u, int fa) {
  sz[u] = 1;
  for (auto& v : e[u]) {
    if (v == fa) continue;
    dfs(v, u);
    sz[u] += sz[v];
    if (sz[v] > n / 2) continue;  // 不满足条件
    if (sz[v] > f[u][0])
      f[u][1] = f[u][0], f[u][0] = sz[v];
    else if (sz[v] > f[u][1])
      f[u][1] = sz[v];
  }
}
void dfs2(int u, int fa, int maxx) {
  cnt[u] = maxx;
  for (auto& v : e[u]) {
    if (v == fa) continue;
    if (n - sz[u] <= n / 2) maxx = max(maxx, n - sz[u]);
    if (f[u][0] == sz[v])
      dfs2(v, u, max(maxx, f[u][1]));
    else
      dfs2(v, u, max(maxx, f[u][0]));
  }
  if ((f[u][0] <= n / 2 && n - sz[u] - cnt[u] <= n / 2) || u == root)
    res[u] = 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  dfs(1, -1);
  dfs1(root, -1);
  dfs2(root, -1, 0);
  for (int i = 1; i <= n; ++i) cout << res[i] << ' ';
  cout << endl;
  return 0;
}
